package com.learn.library;

import com.learn.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/*@Service
public class PersonService {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<Person> getlist() {
        String sql = "select id,name,age,sex,createtime,updatetime from person";
        return (List<Person>) jdbcTemplate.query(sql, new RowMapper<Person>() {
            public Person mapRow(ResultSet rs, int rowNum) throws SQLException {
                Person person = new Person();
                person.setId( rs.getInt("id") );
                person.setName( rs.getString("name") );
                person.setAge( rs.getInt("age") );
                person.setSex( rs.getInt("sex") );
                person.setCreatetime( rs.getInt("createtime") );
                person.setUpdatetime( rs.getString("updatetime") );
                return person;
            }
        });
    }

}*/
